#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 5e5 + 10;

LL n, a[N], tmp[N];
LL ans;

void merge(int l, int r)
{
	if(l >= r) return;
	int mid = l + r >> 1;
	merge(l, mid), merge(mid + 1, r);
	int i = l, j = mid + 1, k = 0;
	while(i <= mid && j <= r)
	{
		if(a[i] > a[j])
		{
			ans += mid - i + 1;
			tmp[k ++] = a[j ++];
		}
		else tmp[k ++] = a[i ++];
	}
	while(i <= mid) tmp[k ++] = a[i ++];
	while(j <= r) tmp[k ++] = a[j ++];
	for(int i = l, k = 0;i <= r;i ++, k ++) a[i] = tmp[k];
}

int main()
{
	cin >> n;
	for(int i = 1;i <= n;i ++) cin >> a[i];
	merge(1, n);
	cout << ans << endl;
	return 0;
}